using System;
using System.Windows.Forms;
namespace com.haopintui.util
{
	public class LogUtil
	{
		public static void log_str(CmsForm cmsForm, string content)
		{
			try
			{
				string text = cmsForm.commonUI.richTextBoxSts.Text;
				if (text.Length > 5000)
				{
					cmsForm.commonUI.richTextBoxSts.Text = string.Concat(new string[]
					{
						DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss"),
						"----",
						content,
						"\n",
						text.Substring(0, 2000)
					});
				}
				else
				{
					cmsForm.commonUI.richTextBoxSts.Text = string.Concat(new string[]
					{
						DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss"),
						"----",
						content,
						"\n",
						text
					});
				}
			}
			catch
			{
				LogUtil.log_call(cmsForm, content);
			}
		}
		public static void log_call(CmsForm cmsForm, string content)
		{
			try
			{
				if (cmsForm.commonUI.richTextBoxSts.InvokeRequired)
				{
					log method = new log(LogUtil.log_call);
					cmsForm.BeginInvoke(method, new object[]
					{
						cmsForm,
						content
					});
				}
				else
				{
					LogUtil.log_str(cmsForm, content);
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show("[messageForThread]出错：" + ex.ToString());
			}
		}
		public static void log_cms_str(CmsForm cmsForm, string content)
		{
			try
			{
				string text = cmsForm.cmsUI.richTextBoxSts.Text;
				if (text.Length > 5000)
				{
					cmsForm.cmsUI.richTextBoxSts.Text = string.Concat(new string[]
					{
						DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss"),
						"----",
						content,
						"\n",
						text.Substring(0, 2000)
					});
				}
				else
				{
					cmsForm.cmsUI.richTextBoxSts.Text = string.Concat(new string[]
					{
						DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss"),
						"----",
						content,
						"\n",
						text
					});
				}
			}
			catch
			{
				LogUtil.log_cms_call(cmsForm, content);
			}
		}
		public static void log_cms_call(CmsForm cmsForm, string content)
		{
			try
			{
				if (cmsForm.cmsUI.richTextBoxSts.InvokeRequired)
				{
					log method = new log(LogUtil.log_cms_call);
					cmsForm.BeginInvoke(method, new object[]
					{
						cmsForm,
						content
					});
				}
				else
				{
					LogUtil.log_cms_str(cmsForm, content);
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show("[messageForThread]出错：" + ex.ToString());
			}
		}
	}
}
